#include "debug.h"
#include "../DDIC/AllDDIC.h"
#include "usbd_cdc_core.h"


void Inter_Demura_Ram(USB_OTG_CORE_HANDLE *pdev,uint8_t  ep_addr,u8 SigMode ,u8 channel,u8* buffer,u16 LP_B7_Data,u16 HS_B7_Data)
{
	u8 buffer1[3];
	u8 RM69350_Inter_Demura_Ram_Cmd_Table[22]={0xfe,0x40,0x0e,0x80,0xfe,0xd2,0x18,0x55,0xfe,0xd0,0x03,0x09,0x4d,0x01,0x78,0x01,0xfe,0x40,0x10,0x82,0xfe,0x00};	
	
	SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data);
	delay_ms(15);
	
        
        if(buffer[7] == RM69350)	{
		for(i=0;i<sizeof(RM69350_Inter_Demura_Ram_Cmd_Table);i++)
		{
			buffer1[0] = 0x02;
			buffer1[1] = RM69350_Inter_Demura_Ram_Cmd_Table[i];
			buffer1[2] = RM69350_Inter_Demura_Ram_Cmd_Table[i+1];
			SSD2828_W_Array(SigMode,channel,buffer1,0);
			delay_ms(50);
			i+=1;
		}		
	}
	
	buffer[0] = 0x2F;
	buffer[1] = 0x01;		

	SSD2828_W_Reg(SigMode,channel,0xB7,HS_B7_Data);
	STM2PC_RM671xx(pdev,CDC_IN_EP,buffer,buffer[2]+3);        																					
}
                                    
void Exit_Demura_Ram(USB_OTG_CORE_HANDLE *pdev,uint8_t  ep_addr,u8 SigMode ,u8 channel,u8* buffer,u16 LP_B7_Data,u16 HS_B7_Data)
{
		


}
                               
void Flash_Write_Demura(USB_OTG_CORE_HANDLE *pdev,uint8_t  ep_addr,u8 SigMode ,u8 channel,u8* buffer,u16 LP_B7_Data,u16 HS_B7_Data)
{
		u32 error_times=0;
		u8 buffer1[3];
		u8 RM69350_Flash_Write_Demura_data_Table[24]={0xfe,0x20,0xf2,0x04,0xfe,0xd2,0x18,0x55,0x12,0x00,0x13,0x00,0x14,0x00,0x15,0x17,0x16,0xFF,0x17,0xFF,0xfe,0x20,0xf2,0x10};			
//		u8 RM69350_Flash_Write_Demura_data_Table_GD16[24]={0xfe,0x20,0xf2,0x04,0xfe,0xd2,0x18,0x55,0x12,0x00,0x13,0x00,0x14,0x00,0x15,0x17,0x16,0xff,0x17,0xff,0xfe,0x20,0xf2,0x10};
		SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data);
		delay_ms(15);	
			
		
		

		
		 if(buffer[7] == RM69350) //350
		{
			buffer[0] = 0x2F;
			buffer[1] = 0x03;		
			buffer[4] = 0x08;	
			
			for(i=0;i<sizeof(RM69350_Flash_Write_Demura_data_Table);i++)
			{
				buffer1[0] = 0x02;
				buffer1[1] = RM69350_Flash_Write_Demura_data_Table[i];
				buffer1[2] = RM69350_Flash_Write_Demura_data_Table[i+1];
				SSD2828_W_Array(SigMode,channel,buffer1,0);
				delay_ms(100);
				i+=1;
			}	
			delay_ms(6000);
			
			buffer1[0] = 0x02;
			buffer1[1] = 0xfe;
			buffer1[2] = 0xe0;
			SSD2828_W_Array(SigMode,channel,buffer1,0);			
			delay_ms(5);
			SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data|0x0080); 
			delay_ms(15);
			SSD2828_W_Reg(SigMode,channel,0xC1,0x0002); //return package  
			do
			{                        
					buffer1[0] = 0x01;
					buffer1[1] = 0x6B;
					SSD2828_W_Array(SigMode,channel,buffer1,0); 
					delay_ms(20);
					buffer[4]=SSD2828_R_Reg(SigMode,channel,0xFF);   
					delay_ms(50);
					if((++error_times)>1000)//15sec timeout error
					{
						buffer[4] = 0x00;	
						goto error_tips0;
					}				
			}while((buffer[4]&0x08)!=0x08);	
		}
		error_tips0:
		SSD2828_W_Reg(SigMode,channel,0xB7,HS_B7_Data);
		STM2PC_RM671xx(pdev,CDC_IN_EP,buffer,buffer[2]+3);           //
}                       

void Flash_Write_Demura2(USB_OTG_CORE_HANDLE *pdev,uint8_t  ep_addr,u8 SigMode ,u8 channel,u8* buffer,u16 LP_B7_Data,u16 HS_B7_Data)
{
	u32 error_time=0;
	u8 buffer1[3];
	u8 RM69350_Flash_Write_Demura_data_Table2[24]={0xfe,0x20,0xf2,0x04,0xfe,0xd2,0x18,0x55,0x12,0x18,0x13,0x00,0x14,0x00,0x15,0x2F,0x16,0xFE,0x17,0xFF,0xfe,0x20,0xf2,0x10};
	SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data);
	delay_ms(15);	
		
	if(buffer[7] == RM69350)	//350
	{		
		buffer[0] = 0x2F;
		buffer[1] = 0x0A;		
		buffer[4] = 0x08;	
		for(i=0;i<sizeof(RM69350_Flash_Write_Demura_data_Table2);i++)
		{
			buffer1[0] = 0x02;
			buffer1[1] = RM69350_Flash_Write_Demura_data_Table2[i];
			buffer1[2] = RM69350_Flash_Write_Demura_data_Table2[i+1];
			SSD2828_W_Array(SigMode,channel,buffer1,0);
			delay_ms(100);
			i+=1;
		}	
		delay_ms(6000);
		
		buffer1[0] = 0x02;
		buffer1[1] = 0xfe;
		buffer1[2] = 0xe0;
		SSD2828_W_Array(SigMode,channel,buffer1,0);			
		delay_ms(5);	
		SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data|0x0080);
		delay_ms(15);		
		SSD2828_W_Reg(SigMode,channel,0xC1,0x0001); //return package  
		do
		{						 
			buffer1[0] = 0x01;
			buffer1[1] = 0x6B;
			SSD2828_W_Array(SigMode,channel,buffer1,0); 
			delay_ms(20);
			buffer[4]=SSD2828_R_Reg(SigMode,channel,0xFF);	 
			delay_ms(50);
			if((++error_time)>1000)//15sec timeout error
			{
				buffer[4] = 0x00;	
				goto error_tips1;
			}
		}while((buffer[4]&0x08)!=0x08);
		error_tips1:
	
		SSD2828_W_Reg(SigMode,channel,0xB7,HS_B7_Data);
		STM2PC_RM671xx(pdev,CDC_IN_EP,buffer,buffer[2]+3);			 //???? ????? Gamma???  ??ok	
	}
}

void Flash_Write_Demura3(USB_OTG_CORE_HANDLE *pdev,uint8_t  ep_addr,u8 SigMode ,u8 channel,u8* buffer,u16 LP_B7_Data,u16 HS_B7_Data)
{
	u32 error_time=0;
	u8 buffer1[3];
	u8 RM69350_Flash_Write_Demura_data_Table2[24]={0xfe,0x20,0xf2,0x04,0xfe,0xd2,0x18,0x55,0x12,0x30,0x13,0x00,0x14,0x00,0x15,0x30,0x16,0xC8,0x17,0x86,0xfe,0x20,0xf2,0x10};
	SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data);
	delay_ms(15);	
	if(buffer[7] == RM69350)	//350
	{		
		buffer[0] = 0x2F;
		buffer[1] = 0x0F;		
		buffer[4] = 0x08;	
		for(i=0;i<sizeof(RM69350_Flash_Write_Demura_data_Table2);i++)
		{
			buffer1[0] = 0x02;
			buffer1[1] = RM69350_Flash_Write_Demura_data_Table2[i];
			buffer1[2] = RM69350_Flash_Write_Demura_data_Table2[i+1];
			SSD2828_W_Array(SigMode,channel,buffer1,0);
			delay_ms(100);
			i+=1;
		}	
		delay_ms(6000);
		
		buffer1[0] = 0x02;
		buffer1[1] = 0xfe;
		buffer1[2] = 0xe0;
		SSD2828_W_Array(SigMode,channel,buffer1,0);			
		delay_ms(5);		
		SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data|0x0080);
		delay_ms(15);	
		SSD2828_W_Reg(SigMode,channel,0xC1,0x0001); //return package  
		do
		{						 
			buffer1[0] = 0x01;
			buffer1[1] = 0x6B;
			SSD2828_W_Array(SigMode,channel,buffer1,0); 
			delay_ms(20);
			buffer[4]=SSD2828_R_Reg(SigMode,channel,0xFF);	 
			delay_ms(50);
			if((++error_time)>1000)//15sec timeout error
			{
				buffer[4] = 0x00;	
				goto error_tips2;
			}
		}while((buffer[4]&0x08)!=0x08);
		error_tips2:
		
		SSD2828_W_Reg(SigMode,channel,0xB7,HS_B7_Data);
		STM2PC_RM671xx(pdev,CDC_IN_EP,buffer,buffer[2]+3);			 //???? ????? Gamma???  ??ok	
	}
}


void Flash_Check_Demura(USB_OTG_CORE_HANDLE *pdev,uint8_t  ep_addr,u8 SigMode ,u8 channel,u8* buffer,u16 LP_B7_Data,u16 HS_B7_Data)
{
	u8 buffer1[3];
	u8 RM69350_Flash_Check_Read_REG_XTX32[2]={0xf8,0xf9};
	u8 RM69350_Flash_Check_Demura_data_Table_XTX32[34]={0xfe,0xd2,0x3d,0xd4,0xa4,0x20,0x0d,0x04,0xfe,0x20,0x09,0x00,0x31,0x00,0x32,0x00,0x33,0x00,0x34,0x30,0x35,0xc8,0x36,0x86,0xfe,0xd2,0xa0,0x21,0x06,0x23};
	u8 RM69350_Flash_Check_Demura_data_Table1_XTX32[4]={0xfe,0x20,0xf4,0xaa};	
//	u8 RM69350_Flash_Check_Demura_data_Table_GD32[36]={0xfe,0xd2,0x06,0x03,0xfe,0x20,0xf3,0x08,0xf3,0x00,0xf3,0x04,0xf3,0x02,0xfe,0x20,0xf2,0x04,0xfe,0xd2,0x12,0x00,0x13,0x00,0x14,0x00,0x15,0x30,0x16,0xC8,0x17,0x84,0xfe,0x20,0xf2,0x01};	
//	u8 RM69350_Flash_Check_Read_REG_GD32[2]={0x69,0x6A};
//	u8 RM69350_Flash_Check_Demura_data_Table_GD16[36]={0xfe,0xd2,0x06,0x03,0xfe,0x20,0xf3,0x08,0xf3,0x00,0xf3,0x04,0xf3,0x02,0xfe,0x20,0xf2,0x04,0xfe,0xd2,0x12,0x00,0x13,0x00,0x14,0x00,0x15,0x17,0xff,0xC9,0x17,0xfe,0xfe,0x20,0xf2,0x01};	
//	u8 RM69350_Flash_Check_Read_REG_GD16[2]={0x69,0x6A};
	SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data);
	delay_ms(15);
	
	
		
	if(buffer[7] ==RM69350)	//350-xtx
	{
		for(i=0;i<sizeof(RM69350_Flash_Check_Demura_data_Table_XTX32);i++)
		{
			buffer1[0] = 0x02;
			buffer1[1] = RM69350_Flash_Check_Demura_data_Table_XTX32[i];
			buffer1[2] = RM69350_Flash_Check_Demura_data_Table_XTX32[i+1];
			SSD2828_W_Array(SigMode,channel,buffer1,0);
			delay_ms(6);
			i+=1;
		}	
		delay_ms(10);
	
		for(i=0;i<sizeof(RM69350_Flash_Check_Demura_data_Table1_XTX32);i++)
		{
			buffer1[0] = 0x02;
			buffer1[1] = RM69350_Flash_Check_Demura_data_Table1_XTX32[i];
			buffer1[2] = RM69350_Flash_Check_Demura_data_Table1_XTX32[i+1];
			SSD2828_W_Array(SigMode,channel,buffer1,0);
			delay_ms(5);
			i+=1;
		}	
		delay_ms(200);
		
		buffer1[0] = 0x02;
		buffer1[1] = 0xfe;
		buffer1[2] = 0x20;
		SSD2828_W_Array(SigMode,channel,buffer1,0);			
		delay_ms(15);	

		SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data|0x0080); 
		SSD2828_W_Reg(SigMode,channel,0xBC,0x0001); 	
		for(i=0;i<sizeof(RM69350_Flash_Check_Read_REG_XTX32);i++) 			
		{	
			SSD2828_W_Reg(SigMode,channel,0xC1,0x0001); //return package						   
			buffer1[0] = 0x01;
			buffer1[1] = RM69350_Flash_Check_Read_REG_XTX32[i];
			SSD2828_W_Array(SigMode,channel,buffer1,0); 
			delay_ms(6);
			buffer[4+i]=SSD2828_R_Reg(SigMode,channel,0xFF);		
		}	

		delay_ms(5);
		buffer[0] = 0x2F;
		buffer[1] = 0x04;				

		SSD2828_W_Reg(SigMode,channel,0xB7,HS_B7_Data);
		STM2PC_RM671xx(pdev,CDC_IN_EP,buffer,buffer[2]+3);			 //???? ????? Gamma???  ??ok			
	}
    
    
    
//	else if(buffer[7] ==RM69350_GD32)	//350
//	{
//		for(i=0;i<sizeof(RM69350_Flash_Check_Demura_data_Table_GD32);i++)
//		{
//			buffer1[0] = 0x02;
//			buffer1[1] = RM69350_Flash_Check_Demura_data_Table_GD32[i];
//			buffer1[2] = RM69350_Flash_Check_Demura_data_Table_GD32[i+1];
//			SSD2828_W_Array(SigMode,channel,buffer1,0);
//			delay_ms(6);
//			i+=1;
//		}	
//	
//		delay_ms(2000);
//		
//		buffer1[0] = 0x02;
//		buffer1[1] = 0xfe;
//		buffer1[2] = 0xe0;
//		SSD2828_W_Array(SigMode,channel,buffer1,0);			
//		delay_ms(15);	

//		SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data|0x0080); 
//		SSD2828_W_Reg(SigMode,channel,0xBC,0x0001); 	
//		for(i=0;i<sizeof(RM69350_Flash_Check_Read_REG_GD32);i++) 			
//		{	
//			SSD2828_W_Reg(SigMode,channel,0xC1,0x0001); //return package						   
//			buffer1[0] = 0x01;
//			buffer1[1] = RM69350_Flash_Check_Read_REG_GD32[i];
//			SSD2828_W_Array(SigMode,channel,buffer1,0); 
//			delay_ms(6);
//			buffer[4+i]=SSD2828_R_Reg(SigMode,channel,0xFF);		
//		}	

//		delay_ms(5);
//		buffer[0] = 0x2F;
//		buffer[1] = 0x04;				

//		SSD2828_W_Reg(SigMode,channel,0xB7,HS_B7_Data);
//		STM2PC_RM671xx(pdev,CDC_IN_EP,buffer,buffer[2]+3);			 //???? ????? Gamma???  ??ok			
//	}	
//	else if(buffer[7] ==RM69350_GD16)	//350
//	{
//		for(i=0;i<sizeof(RM69350_Flash_Check_Demura_data_Table_GD16);i++)
//		{
//			buffer1[0] = 0x02;
//			buffer1[1] = RM69350_Flash_Check_Demura_data_Table_GD16[i];
//			buffer1[2] = RM69350_Flash_Check_Demura_data_Table_GD16[i+1];
//			SSD2828_W_Array(SigMode,channel,buffer1,0);
//			delay_ms(6);
//			i+=1;
//		}		
//		delay_ms(2000);
//		
//		buffer1[0] = 0x02;
//		buffer1[1] = 0xfe;
//		buffer1[2] = 0xe0;
//		SSD2828_W_Array(SigMode,channel,buffer1,0);			
//		delay_ms(15);	

//		SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data|0x0080); 
//		SSD2828_W_Reg(SigMode,channel,0xBC,0x0001); 	
//		for(i=0;i<sizeof(RM69350_Flash_Check_Read_REG_GD32);i++) 			
//		{	
//			SSD2828_W_Reg(SigMode,channel,0xC1,0x0001); //return package						   
//			buffer1[0] = 0x01;
//			buffer1[1] = RM69350_Flash_Check_Read_REG_GD16[i];
//			SSD2828_W_Array(SigMode,channel,buffer1,0); 
//			delay_ms(6);
//			buffer[4+i]=SSD2828_R_Reg(SigMode,channel,0xFF);		
//		}	

//		delay_ms(5);
//		buffer[0] = 0x2F;
//		buffer[1] = 0x04;				

//		SSD2828_W_Reg(SigMode,channel,0xB7,HS_B7_Data);
//		STM2PC_RM671xx(pdev,CDC_IN_EP,buffer,buffer[2]+3);			 //???? ????? Gamma???  ??ok			
//	}
//    
//    
//    
//    
//    



}
                                  
void Flash_Erase_Demura(USB_OTG_CORE_HANDLE *pdev,uint8_t  ep_addr,u8 SigMode ,u8 channel,u8* buffer,u16 LP_B7_Data,u16 HS_B7_Data)
{
	if(buffer[7] == RM69350)
	{
		u8 buffer1[3];
		u8 RM69350_Flash_Erase_Demura_data_Table[10]={0xfe,0xd2,0x18,0x55,0xfe,0x20,0xf2,0x04,0xf3,0x01};
		u8 Read_REG=0x6B;
		SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data);
		delay_ms(15);
	
		for(i=0;i<sizeof(RM69350_Flash_Erase_Demura_data_Table);i++)
		{
			buffer1[0] = 0x02;
			buffer1[1] = RM69350_Flash_Erase_Demura_data_Table[i];
			buffer1[2] = RM69350_Flash_Erase_Demura_data_Table[i+1];
			SSD2828_W_Array(SigMode,channel,buffer1,0);
			delay_ms(5);
			i+=1;
		}
		delay_ms(10);	
		buffer1[0] = 0x02;
		buffer1[1] = 0xfe;
		buffer1[2] = 0xe0;
		SSD2828_W_Array(SigMode,channel,buffer1,0);			
		delay_ms(20000);		
		SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data|0x0080); 
		SSD2828_W_Reg(SigMode,channel,0xBC,0x0001); 
		SSD2828_W_Reg(SigMode,channel,0xC1,0x0002); //return package  
		do
		{						 
			buffer1[0] = 0x01;
			buffer1[1] = Read_REG;
			SSD2828_W_Array(SigMode,channel,buffer1,0); 
			delay_ms(6);
			buffer[4]=SSD2828_R_Reg(SigMode,channel,0xFF);		
		}while((buffer[4]&0x08)!=0x08);
		delay_ms(5);
		buffer[0] = 0x2F;
		buffer[1] = 0x05;		
		buffer[4] = 0x08;	
		
		SSD2828_W_Reg(SigMode,channel,0xB7,HS_B7_Data);
		STM2PC_RM671xx(pdev,CDC_IN_EP,buffer,buffer[2]+3);
	}
	
    
    
    
    
    
    
    
    
    
    
    
}

void Flash_Demura_OTP(USB_OTG_CORE_HANDLE *pdev,uint8_t  ep_addr,u8 SigMode ,u8 channel,u8* buffer,u16 LP_B7_Data,u16 HS_B7_Data)
{
    
    



}

void Enable_Flash_Control(USB_OTG_CORE_HANDLE *pdev,uint8_t  ep_addr,u8 SigMode ,u8 channel,u8* buffer,u16 LP_B7_Data,u16 HS_B7_Data)
{
	u8 buffer1[3];	
//	u8 RM67298_Enable_Flash_Control[4] = {0xfe, 0x20, 0xf3, 0x02};
//	u8 RM67298_Enable_Flash_Read_REG[3] = {0xEA,0xEB,0xEC};
	u8 RM69350_Enable_Flash_Control_XTX32[30] = {0xfe,0xd2,0x01,0xcf,0xfe,0xd2,0x04,0x85,0xfe,0x70,0x2d,0x51,0x04,0x0b,0x05,0x60,0x2b,0x16,0xfe,0x20,0xf3,0x08,0xf3,0x00,0xf3,0x04,0xf3,0x02,0xfe,0xe0};
	u8 RM69350_Enable_Flash_Read_REG_XTX32[3] = {0x6d,0x6e,0x6f};	
//	u8 RM69350_Enable_Flash_Contro_GD32[24] = {0xfe,0xd2,0x01,0xcf,0xfe,0x40,0x4D,0x20,0xfe,0xD2,0x05,0x18,0xFE,0x20,0xF3,0x08,0xF3,0x00,0xf3,0x04,0xf3,0x02,0xfe,0xe0};
//	u8 RM69350_Enable_Flash_Read_REG_GD32[3]= {0x6d,0x6e,0x6f};
//	u8 RM692AX_Enable_Flash_Control[10] = {0xfe, 0x26, 0xf3, 0x02, 0x18, 0x1C, 0x19, 0xEC, 0x1A, 0xF0};
//	u8 RM692AX_Enable_Flash_Read_REG[3] = {0xEA,0xEB,0xEC};
	
	
	if(buffer[7] == RM69350)	//350-XTX32
	{
		SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data);
		delay_ms(15);
		for(i=0;i<sizeof(RM69350_Enable_Flash_Control_XTX32);i++)
		{
		buffer1[0] = 0x02;
		buffer1[1] = RM69350_Enable_Flash_Control_XTX32[i];
		buffer1[2] = RM69350_Enable_Flash_Control_XTX32[i+1];
		SSD2828_W_Array(SigMode,channel,buffer1,0);
		delay_ms(15);
		i+=1;
		}
		SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data|0x0080); 
		SSD2828_W_Reg(SigMode,channel,0xBC,0x0001); 
		for( i = 0; i< 3;i++)				
		{	
			SSD2828_W_Reg(SigMode,channel,0xC1,0x0001); //return package						   
			buffer1[0] = 0x01;
			buffer1[1] = RM69350_Enable_Flash_Read_REG_XTX32[i];
			SSD2828_W_Array(SigMode,channel,buffer1,0); 
			delay_ms(6);
			buffer[4+i]=SSD2828_R_Reg(SigMode,channel,0xFF);		
		}
		delay_ms(5);
		SSD2828_W_Reg(SigMode,channel,0xB7,HS_B7_Data);
		STM2PC_RM671xx(pdev,CDC_IN_EP,buffer,buffer[2]+3);			
	}
	
	
}

void Demura_Function_ON(USB_OTG_CORE_HANDLE *pdev,uint8_t  ep_addr,u8 SigMode ,u8 channel,u8* buffer,u16 LP_B7_Data,u16 HS_B7_Data)
{
    if(buffer[7] == RM69350)
	{
		u8 buffer1[3];
		u8 RM69350_Demura_Function_ON_Table[8] = {0xfe, 0xd2, 0x0e, 0xc0, 0x0f, 0x7f, 0xaa, 0x01};
		SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data);
		delay_ms(15);

		for(i=0;i<sizeof(RM69350_Demura_Function_ON_Table);i++)
		{
		buffer1[0] = 0x02;
		buffer1[1] = RM69350_Demura_Function_ON_Table[i];
		buffer1[2] = RM69350_Demura_Function_ON_Table[i+1];
		SSD2828_W_Array(SigMode,channel,buffer1,0);
		delay_ms(5);
		i+=1;
		}
		delay_ms(5);
		buffer[0] = 0x2F;
		buffer[1] = 0x07;		
		SSD2828_W_Reg(SigMode,channel,0xB7,HS_B7_Data);
		STM2PC_RM671xx(pdev,CDC_IN_EP,buffer,buffer[2]+3);	
	}
	
}

void Demura_Function_OFF(USB_OTG_CORE_HANDLE *pdev,uint8_t  ep_addr,u8 SigMode ,u8 channel,u8* buffer,u16 LP_B7_Data,u16 HS_B7_Data)
{
        if(buffer[7] == RM69350)
	{
		u8 buffer1[3];
		u8 RM69350_Demura_Function_OFF_Table[8] = {0xfe, 0xd2, 0x0e, 0xc0, 0x0f, 0x7f, 0xaa, 0x81};
		SSD2828_W_Reg(SigMode,channel,0xB7,LP_B7_Data);
		delay_ms(15);

		for(i=0;i<sizeof(RM69350_Demura_Function_OFF_Table);i++)
		{
			buffer1[0] = 0x02;
			buffer1[1] = RM69350_Demura_Function_OFF_Table[i];
			buffer1[2] = RM69350_Demura_Function_OFF_Table[i+1];
			SSD2828_W_Array(SigMode,channel,buffer1,0);
			delay_ms(5);
			i+=1;
		}
		delay_ms(5);
		buffer[0] = 0x2F;
		buffer[1] = 0x08;				
		SSD2828_W_Reg(SigMode,channel,0xB7,HS_B7_Data);
		STM2PC_RM671xx(pdev,CDC_IN_EP,buffer,buffer[2]+3);			 //???? ????? Gamma???  ??ok	
	}
	
}









void ProcessForDmuR59( USB_OTG_CORE_HANDLE *pdev,uint8_t  ep_addr,u8 SigMode ,u8 channel,u8 buffer[],u16 LP_B7_Data,u16 HS_B7_Data)
{

  switch(USB_Rx_Buffer[1])
	{
    
         
    
    
    
    }  
    
    
    
    
    
    
    
    
    
    
    
}    
    
    